/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	///  使用物品的参数
	/// module : item
	/// </summary>
	public class UseItemRequestPOD : IPOD 
    {
        public readonly static Func<UseItemRequestPOD> FACTORY = () => new UseItemRequestPOD();
		public static Func<UseItemRequestPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public long itemId;
		/// <summary>
        /// 
        /// </summary>
		public int itemCid;
		/// <summary>
        /// 
        /// </summary>
		public int num;
		/// <summary>
        ///  选择的下标(从0开始）
        /// </summary>
        private List<int> m_chooses;
		
		
        public List<int> chooses
        {
            get
            {
                if(m_chooses == null)
                {
                    m_chooses = new();
                }
                return m_chooses;
            }
            private set => m_chooses = value;
        }
        public List<int> unsafe_chooses
        {
        	get => m_chooses;
        	set => m_chooses = value;
        }
		
		/*-- constructors --*/
		public UseItemRequestPOD() {}
		public UseItemRequestPOD(long itemId, int itemCid, int num, List<int> chooses) {
			this.itemId = itemId;
			this.itemCid = itemCid;
			this.num = num;
			this.m_chooses = chooses;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_long(itemId);
            _out.Write_int(itemCid);
            _out.Write_int(num);
            _out.Write_list_int(m_chooses); 
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            itemId = _in.Read_long();
            if(!_in.HasRemaining()) return;
            itemCid = _in.Read_int();
            if(!_in.HasRemaining()) return;
            num = _in.Read_int();
            if(!_in.HasRemaining()) return;
            m_chooses = _in.Read_list_int();
        }
		
		public UseItemRequestPOD Clone() {
            UseItemRequestPOD o = DynamicFactory();
            o.itemId = itemId;
            o.itemCid = itemCid;
            o.num = num;
            if (m_chooses != null) {
                o.m_chooses = new (m_chooses);
            }
            return o;
        }
        
        public void Clear() {
            itemId = default;
            itemCid = default;
            num = default;
            m_chooses = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "UseItemRequestPOD [";
			str += "itemId=";
			str += itemId;
			str += ", itemCid=";
			str += itemCid;
			str += ", num=";
			str += num;
			str += ", chooses=";
			str += m_chooses.ToString<int>();
			str += "]";
			return str;
		}
		
	}
}